<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			function add(){
				var num1 = document.getElementById("num1").value;
				var num2 = document.getElementById("num2").value;
				var result = parseInt(num1) + parseInt(num2);
				console.log(result);
				var resultInput = document.getElementById("result");
				resultInput.value = result;
			}
			function cal(type){
				var num1 = document.getElementById("num1").value;
				var num2 = document.getElementById("num2").value;
				var result;
				switch(type){
					case "+":
						result = parseInt(num1) + parseInt(num2);
						break;
					case "-":
						result = parseInt(num1) - parseInt(num2);
						break;
					case "*":
						result = parseInt(num1) * parseInt(num2);
						break;
					case "/":
						result = parseInt(num1) / parseInt(num2);
						break;
					default:
						break;
				}
				console.log(result);
				var resultInput = document.getElementById("result");
				resultInput.value = result;
			}
		</script>
	</head>
	<body>
		<p>简易计算器</p>
		<table>
			<tr>
				<td>第一个数</td>
				<td>
					<input type="text"id="num1" />
				</td>
			</tr>
			<tr>
				<td>第二个数</td>
				<td>
					<input type="text"id="num2" />
				</td>
			</tr>
			<tr>
				<td>
					<input type="button" value="+" onclick="cal('+')" />
					<input type="button" value="-" onclick="cal('-')" />
					<input type="button" value="*" onclick="cal('*')" />
					<input type="button" value="/" onclick="cal('/')" />
				</td>
			</tr>
			<tr>
				<td>
					计算结果
				</td>
				<td>
					<input type="text" id="result" />
				</td>
			</tr>
		</table>
	</body>
</html>
